home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 23 / CU Amiga - Super CD-ROM 23 (June 1998).iso / CreatingGames / Utilities / Asm / AB3DIIsrc / Graphics / FASTC2P.LZH / c2p / Startup_macros.i < prev    next >
Encoding:
Text File  |  1995-10-13  |  4.6 KB  |  310 lines

  1.  
  2. ; Startup MACROs - Copyright Ludde'95
  3.  
  4.     include "include:lvo3.0/exec_lib.i"
  5.     include "include:lvo3.0/dos_lib.i"
  6.     include "include:lvo3.0/graphics_lib.i"
  7.     include    "include:hardware/dmabits.i"
  8.     include    "include:hardware/intbits.i"
  9.     include    "include:exec/memory.i"
  10.  
  11. _StartupCode        =    1
  12.  
  13.  
  14. MLeft    =    $2000
  15. MRight    =    $4000
  16.  
  17.  
  18. ;----------------------------------------------------------
  19.  
  20. BlitterWait:    MACRO        ;None
  21.  
  22. .blitwait\@:
  23.     btst    #14-8,$dff002
  24.     bne    .blitwait\@
  25.  
  26.         ENDM
  27.  
  28. ;-------------------------------------------------------------------
  29.  
  30. RasterWait:    MACRO        ;RaserLine
  31.  
  32. .rast\@:
  33.     move.l    $dff004,d0
  34.     lsr.l    #8,d0
  35.     and.l    #$1ff,d0
  36.     cmp.w    #\1,d0
  37.     bne.s    .rast\@
  38. .rast2\@:
  39.     move.l    $dff004,d0
  40.     lsr.l    #8,d0
  41.     and.l    #$1ff,d0
  42.     cmp.w    #\1,d0
  43.     beq.s    .rast2\@
  44.  
  45.         ENDM
  46.  
  47. ;-------------------------------------------------------------------
  48.  
  49. RastPos:    MACRO        ;RasterPos Destination
  50.  
  51.     move.l  $dff004,d0    
  52.     lsr.l   #8,d0        
  53.     and.l   #$1FF,d0    
  54.     move.w  d0,\1        
  55.  
  56.         ENDM
  57.  
  58. ;-------------------------------------------------------------------
  59.  
  60. SetBitmap:    MACRO        ;Screen,bitplspointers,#.of.bitpls,size,(step)
  61.  
  62.     lea.l    \1,a0
  63.     lea.l    \2,a1
  64.     moveq    #\3-1,d1
  65. .anextpl\@:
  66.     move.l    a0,d0
  67.     move.w    d0,6(a1)
  68.     swap    d0
  69.     move.w    d0,2(a1)
  70.  
  71.     IFNE    NARG-5
  72.     addq.l    #8,a1
  73.     ELSE
  74.     lea.l    \5(a1),a1
  75.     ENDIF
  76.     
  77.     lea.l    \4(a0),a0
  78.     dbra    d1,.anextpl\@
  79.  
  80.         ENDM
  81.  
  82. ;----------------------------------------------------------
  83.  
  84. CALL:        MACRO        ;LibCall(a?)
  85.  
  86.     jsr    _LVO\1
  87.  
  88.         ENDM
  89.  
  90. ;---------------------------------------------------------------
  91.  
  92. OpenLib:    MACRO        ;LibraryName,LibraryBase
  93.  
  94.     move.l    4.w,a6
  95.     lea.l    \1,a1
  96.     CALL    OldOpenLibrary(a6)
  97.     move.l    d0,\2
  98.  
  99.         ENDM
  100.  
  101. CloseLib:    MACRO        ;LibraryBase
  102.  
  103.     move.l    4.w,a6
  104.     move.l    \1,a1
  105.     CALL    CloseLibrary(a6)
  106.  
  107.         ENDM
  108.  
  109.  
  110. ;---------------------------------------------------------------
  111. SetDMA:        MACRO        ;DMA bits
  112.  
  113.         move.w    #DMAF_SETCLR!\1,$dff096
  114.  
  115.         ENDM
  116. ;---------------------------------------------------------------
  117. SetINT:        MACRO        ;INTENA bits
  118.  
  119.         move.w    #INTF_SETCLR!\1,$dff09a
  120.  
  121.         ENDM
  122.  
  123. ;---------------------------------------------------------------
  124. SetINTQ:    MACRO        ;INTENA bits
  125.  
  126.         move.w    #INTF_SETCLR!\1,$dff09c
  127.  
  128.         ENDM
  129. ;---------------------------------------------------------------
  130. ClrINT:        MACRO        ;ALL or INTENA bits
  131.  
  132.     IFC    "\1","ALL"
  133.         move.w    #$7FFF,$dff09a
  134.     ELSE
  135.     move.w    #\1,$dff09a
  136.     ENDIF    
  137.  
  138.         ENDM
  139.  
  140. ;---------------------------------------------------------------
  141. ClrINTQ:    MACRO        ;ALL or INTENA bits
  142.  
  143.     IFC    "\1","ALL"
  144.         move.w    #$7FFF,$dff09c
  145.     ELSE
  146.     move.w    #\1,$dff09c
  147.     ENDIF    
  148.  
  149.         ENDM
  150. ;---------------------------------------------------------------
  151. ClrDMA:        MACRO        ;ALL or DMA bits
  152.  
  153.     IFC    "\1","ALL"
  154.  
  155.         move.w    #$3FFF,$dff096
  156.  
  157.     ELSE
  158.  
  159.     move.w    #\1,$dff096
  160.  
  161.     ENDIF    
  162.  
  163.         ENDM
  164. ;---------------------------------------------------------------
  165. SetCop:        MACRO        ;CopperList
  166.  
  167.     move.l    #\1,$dff080
  168.     clr.w    $dff088
  169.  
  170.         ENDM
  171.  
  172. ;---------------------------------------------------------------
  173.  
  174. SetCop2:    MACRO        ;CopperList
  175.  
  176.     move.l    #\1,$dff084
  177.     clr.w    $dff08a
  178.  
  179.         ENDM
  180.  
  181.  
  182. ;----------------------------------------------------------
  183.     
  184. _ReadFile:    MACRO
  185.     move.l    DosBase,a6
  186.  
  187.     move.l    #1005,d2
  188.     CALL    Open(a6)
  189.  
  190.     move.l    d0,d1
  191.      move.l    (sp)+,d2
  192.     move.l    (sp)+,d3
  193.  
  194.     move.l    d0,-(sp)
  195.     CALL    Read(a6)
  196.  
  197.     move.l    (sp)+,d1
  198.     CALL    Close(A6)
  199.  
  200.         ENDM
  201.  
  202. ReadFile:    MACRO        ;Filename,Buffer,Size
  203.  
  204.     movem.l    d0-a6,-(sp)
  205.  
  206.     tst.l    DosBase
  207.     bne.b    .Old
  208.  
  209.     OpenLib        DosName,DosBase
  210.  
  211.     movem.l    (sp),d0-a6
  212.  
  213.     move.l    \3,-(sp)
  214.     move.l    \2,-(sp)
  215.     move.l    \1,d1
  216.     _ReadFile
  217.  
  218.     CloseLib    DosBase
  219.     bra.b    .New
  220. .Old:
  221.     move.l    \3,-(sp)
  222.     move.l    \2,-(sp)
  223.     move.l    \1,d1
  224.     _ReadFile
  225.  
  226. .New:
  227.     movem.l    (sp)+,d0-a6
  228.  
  229.         ENDM
  230.  
  231. ;----------------------------------------------------------
  232.     
  233. WriteFile:    MACRO        ;Filename,Buffer,Size
  234.  
  235.     movem.l    d0-a6,-(sp)
  236.  
  237.     move.l    DosBase,a6
  238.  
  239.     move.l    #\1,d1
  240.     move.l    #1006,d2
  241.     CALL    Open(a6)
  242.     move.l    d0,-(sp)
  243.     move.l    d0,d1
  244.     move.l    #\2,d2
  245.     move.l    #\3,d3
  246.     CALL    Write(a6)
  247.     move.l    (sp)+,d1
  248.     CALL    Close(A6)
  249.  
  250.     movem.l    (sp)+,d0-a6
  251.  
  252.         ENDM
  253.  
  254. ;---------------------------------------------------------------
  255. AllocMem:    MACRO        ;Memtype,Size
  256.     
  257.     movem.l    d1/a0-a1/a6,-(sp)
  258.     move.l    \2,d0
  259.     move.l    #MEMF_\1,d1
  260.     move.l    4.w,a6
  261.     CALL    AllocMem(a6)
  262.     movem.l    (sp)+,d1/a0-a1/a6
  263.     tst.l    d0
  264.  
  265.         ENDM
  266.     
  267. ;---------------------------------------------------------------
  268.  
  269. SaveSystem:    MACRO
  270.  
  271.     jsr    _SaveSystem
  272.  
  273.         ENDM
  274.  
  275.  
  276. RestoreSystem:    MACRO
  277.  
  278.     jsr    _RestoreSystem
  279.  
  280.         ENDM
  281.  
  282. ;---------------------------------------------------------------
  283.  
  284. WaitMouse:    MACRO
  285.  
  286.     IFEQ    (NARG-2)!((~\1)&$2000)
  287.     btst    #6,$bfe001
  288.     bne    \2
  289.     ENDIF
  290.  
  291.     IFEQ    (NARG-2)!((~\1)&$4000)
  292.     btst    #10,$dff016
  293.     bne    \2
  294.     ENDIF
  295.     
  296.     IFEQ    (NARG-1)!((~\1)&$2000)
  297. .w\@:    btst    #6,$bfe001
  298.     bne    .w\@
  299.     ENDIF
  300.  
  301.     IFEQ    (NARG-1)!((~\1)&$4000)
  302. .w\@:    btst    #10,$dff016
  303.     bne    .w\@
  304.     ENDIF
  305.  
  306.         ENDM
  307.  
  308. ;---------------------------------------------------------------
  309.  
  310.